import Main from '@/views/Main.vue';

export const appName = "sys_app";

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: 'Login - 登录'
  },
  component: () => import('@/views/login.vue')
};

export const page404 = {
  path: '/*',
  name: 'error-404',
  meta: {
    title: '404-页面不存在'
  },
  component: () => import('@/views/error-page/404.vue')
};

export const page403 = {
  path: '/403',
  meta: {
    title: '403-权限不足'
  },
  name: 'error-403',
  component: () => import('@//views/error-page/403.vue')
};

export const page500 = {
  path: '/500',
  meta: {
    title: '500-服务端错误'
  },
  name: 'error-500',
  component: () => import('@/views/error-page/500.vue')
};
//
// export const preview = {
//   path: '/preview',
//   name: 'preview',
//   component: () => import('@/views/form/article-publish/preview.vue')
// };
//
export const locking = {
  path: '/locking',
  name: 'locking',
  title: '锁屏',
  component: () => import('@/views/main-components/lockscreen/components/locking-page.vue')
};

export const otherRouter = {
  path: '/',
  name: 'otherRouter',
  title: '',
  redirect: '/home',
  component: Main,
  children: [
    {
      needAccess: true,
      path: 'ownspace',
      title: '个人中心',
      name: 'ownspace_index',
      component: () => import('@/views/own-space/own-space.vue')
    },
    {
      needAccess: true,
      path: 'home',
      title: '主页',
      name: 'home_index',
      component: () => import('@/views/appRoot/dashboard/index.vue')
    },
    {
      path: 'customer/company-mgt/detail/:id',
      title: '企业详情',
      name: 'customer_company-mgt-detail',
      component: () => import('@/views/appRoot/customer/company-mgt/details.vue')
    },
    {
      path: 'customer/customer-mgt/detail/:id',
      title: '联系人详情',
      name: 'customer_customer-mgt-detail',
      component: () => import('@/views/appRoot/customer/customer-mgt/details.vue')
    },
    {
      path: 'contract/my-contract/detail/:id/:status/:creator',
      title: '我的合同详情',
      name: 'contract_my-contract-detail',
      component: () => import('@/views/appRoot/contract/my-contract/details.vue')
    },
    {
      path: 'contract/contract-check/detail/:id',
      title: '合同审批详情',
      name: 'contract_contract-check-detail',
      component: () => import('@/views/appRoot/contract/contract-check/details.vue')
    },
    {
      path: 'contract/fi-check/detail/id',
      title: '财务专员审批详情',
      name: 'contract_fi-check-detail',
      component: () => import('@/views/appRoot/contract/fi-check/details.vue')
    },
    {
      path: 'hr/employee-mgt/detail/:id',
      title: '职员详情',
      name: 'hr_employee-mgt-detail',
      component: () => import('@/views/appRoot/hr/employee-mgt/details.vue')
    },
    {
      path: 'fi/income-record-mgt/detail/:id',
      title: '回款详情',
      name: 'fi_income-record-mgt-detail',
      component: () => import('@/views/appRoot/fi/income-record-mgt/details.vue')
    },
    {
      path: 'product/product-mgt/detail',
      title: '产品详情',
      name: 'product_product-mgt-detail',
      component: () => import('@/views/appRoot/product/product-mgt/details.vue')
    },
    {
      path: 'ticket/my-ticket/detail/:id',
      title: '我的发票详情',
      name: 'ticket_my-ticket-detail',
      component: () => import('@/views/appRoot/ticket/my-ticket/details.vue')
    },
    {
      path: 'ticket/check-ticket/detail/:id',
      title: '发票审核详情',
      name: 'ticket_check-ticket-detail',
      component: () => import('@/views/appRoot/ticket/check-ticket/details.vue')
    }
  ]
};

export const appRouter = [
  {
    path: '/hr',
    icon: 'ios-people',
    title: '人力资源管理',
    name: 'hr',
    component: Main,
    redirect: '/hr/employee-mgt',
    children: [
      {
        path: 'employee-mgt',
        needAccess: true,
        title: '人员管理',
        icon: 'ios-person',
        name: 'hr_employee-mgt',
        component: () => import('@/views/appRoot/hr/employee-mgt/index.vue')
      }, {
        path: 'org',
        needAccess: true,
        title: '组织架构管理',
        icon: 'person-stalker',
        name: 'hr_org',
        component: () => import('@/views/appRoot/hr/org-mgt/index.vue')
      },
      {
        path: 'position-mgt',
        needAccess: true,
        title: '职位管理',
        icon: 'briefcase',
        name: 'hr_position-mgt',
        component: () => import('@/views/appRoot/hr/position-mgt/index.vue')
      }
    ]
  },
  {
    path: '/fi',
    icon: 'social-usd',
    title: '财务系统',
    name: 'fi',
    component: Main,
    redirect: '/fi/income-record-mgt',
    children: [
      {
        path: 'receivable-mgt',
        needAccess: true,
        title: '可确认收入',
        icon: 'archive',
        name: 'fi_receivable-mgt',
        component: () => import('@/views/appRoot/fi/receivable-mgt/index.vue')
      },{
        path: 'income-record-mgt',
        needAccess: true,
        title: '回款记录',
        icon: 'arrow-graph-up-right',
        name: 'fi_income-record-mgt',
        component: () => import('@/views/appRoot/fi/income-record-mgt/index.vue')
      }
    ]
  },
  {
    path: '/customer',
    icon: 'android-contacts',
    title: '客户管理',
    name: 'customer',
    component: Main,
    children: [
      {
        path: 'company-mgt',
        needAccess: true,
        title: '客户',
        icon: 'person-stalker',
        name: 'customer_company-mgt',
        component: () => import('@/views/appRoot/customer/company-mgt/index.vue')
      },{
        path: 'customer-mgt',
        needAccess: true,
        title: '联系人',
        icon: 'ios-person',
        name: 'customer_customer-mgt',
        component: () => import('@/views/appRoot/customer/customer-mgt/index.vue')
      }
    ]
  },
  {
    path: '/product',
    icon: 'paper-airplane',
    title: '产品管理',
    name: 'product',
    component: Main,
    children: [
      {
        path: 'product-mgt',
        needAccess: true,
        title: '公司产品管理',
        icon: 'android-cart',
        name: 'product_product-mgt',
        component: () => import('@/views/appRoot/product/product-mgt/index.vue')
      },
      // {
      //   path: 'product-type-mgt',
      //   title: '产品类型维护',
      //   icon: 'paperclip',
      //   name: 'product_product-type-mgt',
      //   component: () => import('@/views/appRoot/product/product-type-mgt/index.vue')
      // }
    ]
  },
  {
    path: '/contract',
    icon: 'filing',
    title: '合同管理',
    name: 'contract',
    component: Main,
    children: [
      {
        path: 'my-contract',
        title: '我的合同',
        needAccess: true,
        icon: 'flag',
        name: 'contract_my-contract',
        component: () => import('@/views/appRoot/contract/my-contract/index.vue')
      },{
        path: 'contract-check',
        needAccess: true,
        title: '合同审批',
        icon: 'bookmark',
        name: 'contract_contract-check',
        component: () => import('@/views/appRoot/contract/contract-check/index.vue')
      },{
        path: 'fi-check',
        needAccess: true,
        title: '财务专员审核',
        icon: 'toggle-filled',
        name: 'contract_fi-check',
        component: () => import('@/views/appRoot/contract/fi-check/index.vue')
      }
    ]
  },
  {
    path: '/ticket',
    icon: 'ios-box',
    title: '发票管理',
    name: 'ticket',
    component: Main,
    children: [
      {
        path: 'my-ticket',
        needAccess: true,
        title: '我的发票',
        icon: 'pin',
        name: 'ticket_my-ticket',
        component: () => import('@/views/appRoot/ticket/my-ticket/index.vue')
      },
      {
        path: 'check-ticket',
        needAccess: true,
        title: '发票审核',
        icon: 'compass',
        name: 'ticket_check-ticket',
        component: () => import('@/views/appRoot/ticket/check-ticket/index.vue')
      }
    ]
  },
  {
    path: '/report',
    icon: 'pie-graph',
    title: '报表管理',
    name: 'report',
    component: Main,
    children: [
      {
        path: 'backpayment-report',
        needAccess: true,
        title: '回款报表',
        icon: 'cube',
        name: 'report_backpayment-report',
        component: () => import('@/views/appRoot/report/backpayment-report/index.vue')
      },
      {
        path: 'receivable-report',
        needAccess: true,
        title: '可确认收入报表',
        icon: 'pricetags',
        name: 'report_receivable-report',
        component: () => import('@/views/appRoot/report/receivable-report/index.vue')
      },{
        path: 'sales-report',
        needAccess: true,
        title: '销售报表',
        icon: 'card',
        name: 'report_sales-report',
        component: () => import('@/views/appRoot/report/sales-report/index.vue')
      },{
        path: 'ticket-report',
        needAccess: true,
        title: '发票报表',
        icon: 'paperclip',
        name: 'report_ticket-report',
        component: () => import('@/views/appRoot/report/ticket-report/index.vue')
      }
    ]
  },
  {
    path: '/system-setting',
    icon: 'gear-a',
    title: '系统设置',
    name: 'system-setting',
    component: Main,
    redirect: '/system-setting/index',
    children: [
      {
        path: 'app',
        needAccess: true,
        title: '应用管理',
        icon: 'monitor',
        name: 'system-setting_app',
        component: () => import('@/views/appRoot/sys/app-mgt/index.vue')
      },
      {
        path: 'role',
        needAccess: true,
        title: '角色管理',
        icon: 'ribbon-b',
        name: 'system-setting_role',
        component: () => import('@/views/appRoot/sys/role-mgt/index.vue')
      },
      {
        path: 'account-mgt',
        needAccess: true,
        title: '账号管理',
        icon: 'android-add-circle',
        name: 'system-setting_account-mgt',
        component: () => import('@/views/appRoot/sys/account-mgt/index.vue')
      },
      {
        path: 'resource',
        needAccess: true,
        title: '功能服务列表',
        icon: 'compass',
        name: 'system-setting_resource',
        component: () => import('@/views/appRoot/sys/resource-viewer/index.vue')
      },
      {
        path: 'entities',
        needAccess: true,
        title: '业务实体列表',
        icon: 'compass',
        name: 'system-setting_entities',
        component: () => import('@/views/appRoot/sys/entity-viewer/index.vue')
      },
      {
        path: 'pages',
        needAccess: true,
        title: '当前应用页面列表',
        icon: 'compass',
        name: 'system-setting_pages',
        component: () => import('@/views/appRoot/sys/app-page-viewer/index.vue')
      },
      {
        path: 'index',
        needAccess: true,
        title: '系统设置',
        icon: 'settings',
        name: 'system-setting_index',
        component: () => import('@/views/appRoot/sys/system-setting/index.vue')
      }
    ]
  },
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
  loginRouter,
  otherRouter,
  ...appRouter,
  locking,
  page500,
  page403,
  page404
];
